<%@page import="java.util.List"%>
<%@page import="com.kmstech.greeting.entities.Greeting" %>
<!doctype html>
<html>
<head>
  <title>Greeting</title>
  <style type="text/css">
    #language, th:FIRST-CHILD, td:FIRST-CHILD {
      width: 4em !important;
    }
    #message, th, td {
      width: 32em;
    }
    th, td {
      border: 1px solid #000;
    }
  </style>
</head>
<body>
  <h1>Message: ${message}</h1>
  <form action="add.do" method="POST">
    <label for="language">Language: </label>
    <input type="text" id="language" name="language" value="${language}" maxlength="2" />
    <label for="message">Message: </label>
    <input type="text" id="message" name="message" value="${message}" maxlength="32" />
    <input type="submit" name="submit" value="Add" />
  </form>
  <table>
    <thead>
	    <tr>
	      <th>Language</th>
	      <th>Message</th>
	    </tr>
    </thead>
    <tbody>
      <%
      List<Greeting> greetings = (List<Greeting>) request.getAttribute("greetings");
      for (Greeting greeting : greetings) { %>
      <tr>
        <td><a href="home.do?lang=<%=greeting.getLanguage() %>"><%=greeting.getLanguage() %></a></td>
        <td><%=greeting.getMessage() %></td>
      </tr>
      <%} %>
    </tbody>
  </table>
</body>
</html>